<?php

namespace app\common\model\wm;

use think\Model;


class Ordergoods extends Model
{

    

    

    // 表名
    protected $name = 'wm_ordergoods';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'goods_info_json'
    ];
    

    



    protected function getGoodsInfoJsonAttr($value,$data)
    {
        return isset($data['goods_info'])?json_decode($data['goods_info'],1):[];
    }
    
    protected function setGoodsInfoAttr($value)
    {
        return is_array($value)?json_encode($value,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE):$value;
    }



    public function order()
    {
        return $this->belongsTo('Order', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
